﻿using RuoVea.ExSugar.Attributes;
using RuoVea.ExSugar.Entity;
using SqlSugar;
using System.ComponentModel;

namespace RuoVea.OmiApi.Article.Entitys;

/// <summary>
/// 标签表
/// </summary>
[SugarTable(nameof(ArtTag), TableDescription = "标签表")]
[Description("标签表")]
[SugarIndex($"IX_{nameof(ArtTag)}_{nameof(Name)}", nameof(Name), OrderByType.Asc, true)] // 标签名称唯一索引
[SugarIndex($"IX_{nameof(ArtTag)}_{nameof(Code)}", nameof(Code), OrderByType.Asc, true)] // 标签别名唯一索引
[SugarIndex($"IX_{nameof(ArtTag)}_{nameof(CreateTime)}", nameof(CreateTime), OrderByType.Desc)]
public class ArtTag : EntityBase
{
    /// <summary>
    /// 标签名称
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Name), columnDescription: "标签名称", Length = 100)]
    public string Name { get; set; }

    /// <summary>
    /// 标签别名(URL友好格式)
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Code), columnDescription: "标签别名(URL友好格式)", Length = 100)]
    public string Code { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Sort), columnDescription: "排序", IsNullable = true, DefaultValue = "10")]
    public int? Sort { get; set; } = 10;

    /// <summary>
    /// 备注
    /// </summary>
    [ConfigSugarColumn(columnKey: nameof(Remark), columnDescription: "备注", IsNullable = true, Length = 500)]
    public string Remark { get; set; }

    /// <summary>
    /// 导航属性 - 文章列表（多对多关系）
    /// </summary>
    [Navigate(typeof(ArtArticleTag), nameof(ArtArticleTag.TagId), nameof(ArtArticleTag.ArticleId))]
    [SugarColumn(IsIgnore = true)]
    public List<ArtArticle> Articles { get; set; }
}